From 36c59989f2c3cc25fceb77199486b7625b000dd2 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 31 Jul 2022 13:35:03 -0600 Subject: [PATCH] change return type get_cache_icon, gs_get_cachetype, gs_get_container to QString. (#898) --- defs.h | 6 +++--- garmin.cc | 2 +- gpx.cc | 4 ++-- html.cc | 11 ++++++----- lowranceusr.cc | 4 ++-- magproto.cc | 2 +- text.cc | 12 ++++++++---- util.cc | 2 +- xcsv.cc | 4 ++-- 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/defs.h b/defs.h index 352c65a33..d576ff683 100644 --- a/defs.h +++ b/defs.h @@ -1076,9 +1076,9 @@ time_t mkgmtime(struct tm* t); bool gpsbabel_testmode(); gpsbabel::DateTime current_time(); QDateTime dotnet_time_to_qdatetime(long long dotnet); -const char* get_cache_icon(const Waypoint* waypointp); -const char* gs_get_cachetype(geocache_type t); -const char* gs_get_container(geocache_container t); +QString get_cache_icon(const Waypoint* waypointp); +QString gs_get_cachetype(geocache_type t); +QString gs_get_container(geocache_container t); QString xml_entitize(const QString& str); QString html_entitize(const QString& str); char* strip_html(const utf_string*); diff --git a/garmin.cc b/garmin.cc index f1e188ba3..38d54e51a 100644 --- a/garmin.cc +++ b/garmin.cc @@ -986,7 +986,7 @@ waypoint_prepare() if (deficon) { icon = gt_find_icon_number_from_desc(deficon, PCX); } else { - if (get_cache_icon(wpt)) { + if (!get_cache_icon(wpt).isEmpty()) { icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX); } else { icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX); diff --git a/gpx.cc b/gpx.cc index b6803bf78..a54b73594 100644 --- a/gpx.cc +++ b/gpx.cc @@ -442,7 +442,7 @@ gs_mktype(const QString& t) return gt_unknown; } -const char* +QString gs_get_cachetype(geocache_type t) { int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]); @@ -468,7 +468,7 @@ gs_mkcont(const QString& t) return gc_unknown; } -const char* +QString gs_get_container(geocache_container t) { int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]); diff --git a/html.cc b/html.cc index e84507f71..ddf0b81c1 100644 --- a/html.cc +++ b/html.cc @@ -90,11 +90,12 @@ HtmlFormat::html_disp(const Waypoint* wpt) const gbfprintf(file_out, ""); if (wpt->gc_data->terr) { gbfprintf(file_out, "

%d%s / %d%s
\n", - (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?"½":"", - (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?"½":""); - gbfprintf(file_out, "%s / %s

", - gs_get_cachetype(wpt->gc_data->type), - gs_get_container(wpt->gc_data->container)); + (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10) ? "½" : "", + (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10) ? "½" : ""); + gbfputs(QStringLiteral("%1 / %2

") + .arg(gs_get_cachetype(wpt->gc_data->type), + gs_get_container(wpt->gc_data->container)), + file_out); } gbfprintf(file_out, "\n"); diff --git a/lowranceusr.cc b/lowranceusr.cc index 03cb38442..de18681bf 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -1346,7 +1346,7 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const gbfputint32(waypt_time, file_out); - if (get_cache_icon(wpt) && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) { + if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) { SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt)); } else { SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr); @@ -1407,7 +1407,7 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt) gbfputint32(2, file_out); int SymbolId, ColorId; - if (get_cache_icon(wpt) && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) { + if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(QLatin1String("Geocache Found")) == 0) { if (writing_version == 4) { SymbolId = lowranceusr4_find_icon_number_from_desc(wpt->icon_descr); } else { diff --git a/magproto.cc b/magproto.cc index e5a278f29..77380bb01 100644 --- a/magproto.cc +++ b/magproto.cc @@ -1359,7 +1359,7 @@ mag_waypt_pr(const Waypoint* waypointp) icon_token = mag_find_token_from_descr(waypointp->icon_descr); } - if (get_cache_icon(waypointp)) { + if (!get_cache_icon(waypointp).isEmpty()) { icon_token = mag_find_token_from_descr(get_cache_icon(waypointp)); } diff --git a/text.cc b/text.cc index 313c379c0..42fa2b456 100644 --- a/text.cc +++ b/text.cc @@ -101,10 +101,14 @@ TextFormat::text_disp(const Waypoint* wpt) } } if (wpt->gc_data->terr) { - gbfprintf(file_out, " - %s / %s - (%d%s / %d%s)\n", - gs_get_cachetype(wpt->gc_data->type), gs_get_container(wpt->gc_data->container), - (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?".5":"", - (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?".5":""); + gbfputs(QStringLiteral(" - %1 / %2 - (%3%4 / %5%6)\n") + .arg(gs_get_cachetype(wpt->gc_data->type), + gs_get_container(wpt->gc_data->container)) + .arg((int)(wpt->gc_data->diff / 10)) + .arg((wpt->gc_data->diff%10) ? ".5" : "") + .arg((int)(wpt->gc_data->terr / 10)) + .arg((wpt->gc_data->terr%10) ? ".5" : ""), + file_out); if (!wpt->gc_data->desc_short.utfstring.isEmpty()) { char* stripped_html = strip_html(&wpt->gc_data->desc_short); gbfprintf(file_out, "\n%s\n", stripped_html); diff --git a/util.cc b/util.cc index b722ee00d..7c7eddbad 100644 --- a/util.cc +++ b/util.cc @@ -724,7 +724,7 @@ QDateTime dotnet_time_to_qdatetime(long long dotnet) * a GPX file from geocaching.com. Thus we sort of make all the other * formats do lookups based on these strings. */ -const char* +QString get_cache_icon(const Waypoint* waypointp) { if (!global_opts.smart_icons) { diff --git a/xcsv.cc b/xcsv.cc index 8adc85cb9..0c9d3e19e 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -1388,12 +1388,12 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) break; case XcsvStyle::XT_GEOCACHE_CONTAINER: /* Geocache Container */ - buff = QString::asprintf(fmp.printfc.constData(), gs_get_container(wpt->gc_data->container)); + buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_container(wpt->gc_data->container))); field_is_unknown = wpt->gc_data->container == gc_unknown; break; case XcsvStyle::XT_GEOCACHE_TYPE: /* Geocache Type */ - buff = QString::asprintf(fmp.printfc.constData(), gs_get_cachetype(wpt->gc_data->type)); + buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_cachetype(wpt->gc_data->type))); field_is_unknown = wpt->gc_data->type == gt_unknown; break; case XcsvStyle::XT_GEOCACHE_HINT: -- 2.30.2